﻿using DDE_Server.Event;
using DDE_Server.View;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NDde.Server;
using DDE_Server.Object;
namespace DDE_Server.Presenter
{
    public class MainPresenter
    {
        MyServer myServer = null;
        private MainForm mainForm = null;
        public MainPresenter(MainForm main) {
            myServer = new MyServer("PJMDispatchStrat");
            myServer.Register();
            if (myServer.IsRegistered) {
                myServer.Advise("*", "*");
            }
            mainForm = main;
            mainForm.DispatchPresenter.DispRateChanged += UpdateResultHandler;
			mainForm.DispatchPresenter.RefreshData();
            mainForm.StrategyPresenter.DataChange += myServer.AdviseData;
        }
        void UpdateResultHandler(object sender, DispRateChangedEventArgs e)
        {
            mainForm.StrategyPresenter.UpdateResult(e.DispRate);
        }
    }
}
